package de.axa.smartfix.monitoring.model.provider;

import java.text.DateFormat;
import java.util.Date;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import de.axa.smartfix.monitoring.model.IMonitor;

public class TreeMonitorLabelProvider extends LabelProvider implements
		ITableLabelProvider {

	private static DateFormat dateFormatter = DateFormat.getDateInstance();

	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof IMonitor) {
			IMonitor monitor = (IMonitor) element;
			switch (columnIndex) {
			case 0:
				return monitor.getName();
			case 1:
				return "" + monitor.getCount();
			case 2:
				Date date = monitor.getOldest();
				if (date == IMonitor.NO_DATE_AVAILABLE)
					return "";
				return dateFormatter.format(date);
			default:
				break;
			}
		}
		return "";
	}
}
